<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
        <script>
            //promise是ES6用来实现异步编程的，是一个构造函数，封装了异步操作，返回true或false.
            const p = new Promise(function(resolve,reject){
                setTimeout(function(){
                    // let data = "数据库中的用户数据";
                    // resolve(data);
                    let err = "调用失败！";
                    reject(err);
                },1000);
            });

            p.then(function(value){
                console.log(value);
            },function(reason){
                console.error(reason);
            })
        </script>
    </body>
</html>